// components/customUl/index.js
Component({
    relations: {
        "../customLi/index": {
            type: "child", //关联的目标节点应为子节点
            linked: function(target) {
                console.log(target.data.tabIndex);

                var _this = this;
                target.calcHeight(function(rect) {
                    _this.data._contentHeight[target.data.tabIndex] = rect.height;
                    if (_this._calcHeightTimer) {
                        clearTimeout(_this._calcHeightTimer)
                    }

                    _this._calcHeightTimer = setTimeout(function() {
                        _this.calcHeight()

                    }, 100);

                });
            },
        },
    },
    options: {
        multipleSlots: true,
    },

    /**
     * 组件的属性列表
     */
    properties: {
        vtabs: {
            type: Array,
            value: [],
        },
    },

    ready() {


    },

    /**
     * 组件的初始数据
     */
    data: {
        _contentHeight: {},
        _heightRecords: [],
    },

    /**
     * 组件的方法列表
     */
    methods: {
        calcHeight() {
            var length = this.data.vtabs.length;
            var _contentHeight = this.data._contentHeight;
            var _heightRecords = [];
            var temp = 0;
            for (var i = 0; i < length; i++) {
                _heightRecords[i] = temp + _contentHeight[i];
                temp = _heightRecords[i];
            }
            console.log(_heightRecords);
            // this.data._heightRecords = _heightRecords;
            this.setData({
                _heightRecords
            })
        },

        onTap() {
            console.log(this.data._heightRecords);

        }
    },
});